home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume89 / unix / rcs.08 < prev    next >
Internet Message Format  |  1989-11-19  |  42KB

  1. Path: xanth!ames!apple!sun-barr!newstop!sun!swap!page
  2. From: page%swap@Sun.COM (Bob Page)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v89i223:  rcs - revision control system, Part08/14
  5. Message-ID: <128099@sun.Eng.Sun.COM>
  6. Date: 19 Nov 89 09:25:16 GMT
  7. Sender: news@sun.Eng.Sun.COM
  8. Lines: 1435
  9. Approved: page@sun.com
  10.  
  11. Submitted-by: rsbx@cbmvax.commodore.com (Raymond S. Brand)
  12. Posting-number: Volume 89, Issue 223
  13. Archive-name: unix/rcs.08
  14.  
  15. # This is a shell archive.
  16. # Remove anything above and including the cut line.
  17. # Then run the rest of the file through 'sh'.
  18. # Unpacked files will be owned by you and have default permissions.
  19. #----cut here-----cut here-----cut here-----cut here----#
  20. #!/bin/sh
  21. # shar: SHell ARchive
  22. # Run the following text through 'sh' to create:
  23. #    rcs/rcs.rcsfiles/rcsbase.h,v
  24. #    rcs/rcs.rcsfiles/rcsdiff.c,v
  25. #    rcs/rcs.rcsfiles/rcsclean.c,v
  26. # This is archive 8 of a 14-part kit.
  27. # This archive created: Sun Nov 19 01:12:09 1989
  28. if `test ! -d rcs`
  29. then
  30.   mkdir rcs
  31.   echo "mkdir rcs"
  32. fi
  33. if `test ! -d rcs/rcs.rcsfiles`
  34. then
  35.   mkdir rcs/rcs.rcsfiles
  36.   echo "mkdir rcs/rcs.rcsfiles"
  37. fi
  38. echo "extracting rcs/rcs.rcsfiles/rcsbase.h,v"
  39. sed 's/^X//' << \SHAR_EOF > rcs/rcs.rcsfiles/rcsbase.h,v
  40. Xhead     4.9;
  41. Xbranch   4.9.2;
  42. Xaccess   ;
  43. Xsymbols  amiga_rcs:4.9.2 cbmvax_source:4.9.1 uunet_june89_dist:4.9;
  44. Xlocks    ; strict;
  45. Xcomment  @ * @;
  46. X
  47. X
  48. X4.9
  49. Xdate     89.05.01.15.17.14;  author narten;  state Exp;
  50. Xbranches 4.9.1.1 4.9.2.1;
  51. Xnext     ;
  52. X
  53. X4.9.1.1
  54. Xdate     89.08.11.01.42.12;  author rsbx;  state Exp;
  55. Xbranches ;
  56. Xnext     ;
  57. X
  58. X4.9.2.1
  59. Xdate     89.10.13.19.16.35;  author rsbx;  state Exp;
  60. Xbranches ;
  61. Xnext     4.9.2.2;
  62. X
  63. X4.9.2.2
  64. Xdate     89.10.15.15.43.52;  author rsbx;  state Exp;
  65. Xbranches ;
  66. Xnext     4.9.2.3;
  67. X
  68. X4.9.2.3
  69. Xdate     89.10.16.19.07.02;  author rsbx;  state Exp;
  70. Xbranches ;
  71. Xnext     4.9.2.4;
  72. X
  73. X4.9.2.4
  74. Xdate     89.11.01.14.43.06;  author rsbx;  state Exp;
  75. Xbranches ;
  76. Xnext     ;
  77. X
  78. X
  79. Xdesc
  80. X@RCS common definitions and data structures.
  81. X@
  82. X
  83. X
  84. X
  85. X4.9
  86. Xlog
  87. X@checked in with -k by rsbx at 89.08.10.16.06.59.
  88. X@
  89. Xtext
  90. X@
  91. X/*
  92. X *                     RCS common definitions and data structures
  93. X */
  94. X#define RCSBASE "$Id: rcsbase.h,v 4.9 89/05/01 15:17:14 narten Exp $"
  95. X
  96. X/* Copyright (C) 1982, 1988, 1989 Walter Tichy
  97. X * All rights reserved.
  98. X *
  99. X * Redistribution and use in source and binary forms are permitted
  100. X * provided that the above copyright notice and this paragraph are
  101. X * duplicated in all such forms and that any documentation,
  102. X * advertising materials, and other materials related to such
  103. X * distribution and use acknowledge that the software was developed
  104. X * by Walter Tichy.
  105. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  106. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  107. X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  108. X *
  109. X * Report all problems and direct all questions to:
  110. X *   rcs-bugs@@cs.purdue.edu
  111. X * 
  112. X
  113. X
  114. X
  115. X
  116. X
  117. X
  118. X
  119. X*/
  120. X
  121. X
  122. X
  123. X/*****************************************************************************
  124. X * INSTRUCTIONS:
  125. X * =============
  126. X * The following should be handled in the Makefile:
  127. X *     For USG Unix, define USG; for BSD Unix, don't (see ifdef USG).
  128. X *     For 4.2 bsd, define V4_2BSD; this will replace the routines
  129. X *     getwd() and rename() with the corresponding ones in the C-library.
  130. X *     V4_2BSD also selects different definitions for the macros NCPFN and NCPPN
  131. X *     (max. number of characters per filename, number of characters per path name).
  132. X *     Define STRICT_LOCKING appropriately (see STRICT_LOCKING).
  133. X * The following need be changed for porting to a different machine:
  134. X *     Define SMALLOG for a machine with small memory (like the PDP11).
  135. X *     SMALLOG conserves space for log messages.
  136. X *     Change BYTESIZ if necessary.
  137. X * If you need to change the comment leaders, update the table comtable[]
  138. X * in rcsfnms.c. (This can wait until you know what a comment leader is.)
  139. X *****************************************************************************
  140. X */
  141. X
  142. X
  143. X/* $Log:    rcsbase.h,v $
  144. X * Revision 4.9  89/05/01  15:17:14  narten
  145. X * botched previous USG fix 
  146. X * 
  147. X * Revision 4.8  89/05/01  14:53:05  narten
  148. X * changed #include <strings.h> -> string.h for USG systems.
  149. X * 
  150. X * Revision 4.7  88/11/08  15:58:45  narten
  151. X * removed defs for functions loaded from libraries
  152. X * 
  153. X * Revision 4.6  88/11/08  12:04:06  narten
  154. X * changes from eggert@@sm.unisys.com (Paul Eggert)
  155. X * 
  156. X * Revision 4.6  88/08/09  19:12:36  eggert
  157. X * Shrink stdio code size; remove lint; permit -Dhshsize=nn.
  158. X * 
  159. X * Revision 4.5  87/12/18  17:06:41  narten
  160. X * made removed BSD ifdef, now uses V4_2BSD
  161. X * 
  162. X * Revision 4.4  87/10/18  10:29:49  narten
  163. X * Updating version numbers
  164. X * Changes relative to 1.1 are actually relative to 4.2
  165. X * 
  166. X * Revision 1.3  87/09/24  14:02:25  narten
  167. X * changes for lint
  168. X * 
  169. X * Revision 1.2  87/03/27  14:22:02  jenkins
  170. X * Port to suns
  171. X * 
  172. X * Revision 1.1  84/01/23  14:50:14  kcs
  173. X * Initial revision
  174. X * 
  175. X * Revision 4.2  83/12/20  16:04:20  wft
  176. X * merged 3.6.1.1 and 4.1 (SMALLOG, logsize).
  177. X * moved setting of STRICT_LOCKING to Makefile.
  178. X * changed DOLLAR to UNKN (conflict with KDELIM).
  179. X * 
  180. X * Revision 4.1  83/05/04  09:12:41  wft
  181. X * Added markers Id and RCSfile.
  182. X * Added Dbranch for default branches.
  183. X * 
  184. X * Revision 3.6.1.1  83/12/02  21:56:22  wft
  185. X * Increased logsize, added macro SMALLOG.
  186. X * 
  187. X * Revision 3.6  83/01/15  16:43:28  wft
  188. X * 4.2 prerelease
  189. X * 
  190. X * Revision 3.6  83/01/15  16:43:28  wft
  191. X * Replaced dbm.h with BYTESIZ, fixed definition of rindex().
  192. X * Added variants of NCPFN and NCPPN for bsd 4.2, selected by defining V4_2BSD.
  193. X * Added macro DELNUMFORM to have uniform format for printing delta text nodes.
  194. X * Added macro DELETE to mark deleted deltas.
  195. X *
  196. X * Revision 3.5  82/12/10  12:16:56  wft
  197. X * Added two forms of DATEFORM, one using %02d, the other %.2d.
  198. X *
  199. X * Revision 3.4  82/12/04  20:01:25  wft
  200. X * added LOCKER, Locker, and USG (redefinition of rindex).
  201. X *
  202. X * Revision 3.3  82/12/03  12:22:04  wft
  203. X * Added dbm.h, stdio.h, RCSBASE, RCSSEP, RCSSUF, WORKMODE, TMPFILE3,
  204. X * PRINTDATE, PRINTTIME, map, and ctab; removed Suffix. Redefined keyvallength
  205. X * using NCPPN. Changed putc() to abort on write error.
  206. X *
  207. X * Revision 3.2  82/10/18  15:03:52  wft
  208. X * added macro STRICT_LOCKING, removed RCSUMASK.
  209. X * renamed JOINFILE[1,2] to JOINFIL[1,2].
  210. X *
  211. X * Revision 3.1  82/10/11  19:41:17  wft
  212. X * removed NBPW, NBPC, NCPW.
  213. X * added typdef int void to aid compiling
  214. X */
  215. X
  216. X
  217. X
  218. X#include <stdio.h>
  219. X#ifdef USG
  220. X#include <string.h>
  221. X#else
  222. X#include <strings.h>
  223. X#endif
  224. X#undef putc         /* will be redefined */
  225. X
  226. X
  227. X#ifdef USG
  228. X#       define rindex    strrchr
  229. X#       define DATEFORM  "%.2d.%.2d.%.2d.%.2d.%.2d.%.2d"
  230. X#else
  231. X#       define DATEFORM  "%02d.%02d.%02d.%02d.%02d.%02d"
  232. X#endif
  233. X/* Make sure one of %02d or %.2d prints a number with a field width 2, with
  234. X * leading zeroes. For example, 0, 1, and 22 must be printed as 00, 01, and
  235. X * 22. Otherwise, there will be problems with the dates.
  236. X */
  237. X
  238. X#define PRINTDATE(file,date) fprintf(file,"%.2s/%.2s/%.2s",date,date+3,date+6)
  239. X#define PRINTTIME(file,date) fprintf(file,"%.2s:%.2s:%.2s",date+9,date+12,date+15)
  240. X/* print RCS format date and time in nice format from a string              */
  241. X
  242. X/*
  243. X * Parameters
  244. X */
  245. X#define BYTESIZ             8 /* number of bits in a byte                   */
  246. X
  247. X/*#define STRICT_LOCKING    0 /* 0 sets the default locking to non-strict;  */
  248. X                              /* used in experimental environments.         */
  249. X                              /* 1 sets the default locking to strict;      */
  250. X                              /* used in production environments.           */
  251. X                  /* STRICT_LOCKING is set in the Makefile!     */
  252. X#ifndef hshsize
  253. X#define hshsize           239 /* hashtable size; MUST be prime and -1 mod 4 */
  254. X                              /* other choices: 547 or 719                  */
  255. X#endif
  256. X
  257. X#define strtsize (hshsize * 50) /* string table size                        */
  258. X#ifdef SMALLOG
  259. X#  define logsize         1024 /* max. size of log message for pdp11        */
  260. X#else
  261. X#  define logsize         4096 /* max. size of log message for others       */
  262. X#endif
  263. X#define revlength          30 /* max. length of revision numbers            */
  264. X#define datelength         20 /* length of a date in RCS format             */
  265. X#define joinlength         20 /* number of joined revisions permitted       */
  266. X#define RCSDIR         "RCS/" /* subdirectory for RCS files                 */
  267. X#define RCSSUF            'v' /* suffix for RCS files                       */
  268. X#define RCSSEP            ',' /* separator for RCSSUF                       */
  269. X#define KDELIM            '$' /* delimiter for keywords                     */
  270. X#define VDELIM            ':' /* separates keywords from values             */
  271. X#define DEFAULTSTATE    "Exp" /* default state of revisions                 */
  272. X#ifdef V4_2BSD
  273. X#  define NCPFN           256 /* number of characters per filename          */
  274. X#  define NCPPN          1024 /* number of characters per pathname          */
  275. X#else
  276. X#  define NCPFN            14 /* number of characters per filename          */
  277. X#  define NCPPN       6*NCPFN /* number of characters per pathname          */
  278. X#endif
  279. X#define keylength          20 /* buffer length for expansion keywords       */
  280. X#define keyvallength NCPPN+revlength+datelength+60
  281. X                              /* buffer length for keyword expansion        */
  282. X
  283. X
  284. X
  285. X#define true     1
  286. X#define false    0
  287. X#define nil      0
  288. X#define elsif    else if
  289. X#define elif     else if
  290. X
  291. X
  292. X/* temporary file names */
  293. X
  294. X#define NEWRCSFILE  ",RCSnewXXXXXX"
  295. X#define DIFFILE     ",RCSciXXXXXX"
  296. X#define TMPFILE1    ",RCSt1XXXXXX"
  297. X#define TMPFILE2    ",RCSt2XXXXXX"
  298. X#define TMPFILE3    ",RCSt3XXXXXX"
  299. X#define JOINFIL2    ",RCSj2XXXXXX"
  300. X#define JOINFIL3    ",RCSj3XXXXXX"
  301. X
  302. X
  303. X#define putc(x,p) (--(p)->_cnt>=0? ((int)(*(p)->_ptr++=(unsigned)(x))):fflsbuf((unsigned)(x),p))
  304. X/* This version of putc prints a char, but aborts on write error            */
  305. X
  306. X#define GETC(in,out,echo) (c=getc(in), echo?putc(c,out):c)
  307. X/* GETC modifies a local variable c; a kludge, but smaller and faster.      */
  308. X/* GETC writes a del-character (octal 177) on end of file                   */
  309. X
  310. X#define WORKMODE(RCSmode) (RCSmode&~0222)|((lockflag||!StrictLocks)?0600:0000)
  311. X/* computes mode of working file: same as RCSmode, but write permission     */
  312. X/* determined by lockflag and StrictLocks.                                  */
  313. X
  314. X
  315. X/* character classes and token codes */
  316. Xenum tokens {
  317. X/* char classes*/  DIGIT, IDCHAR, NEWLN, LETTER, PERIOD, SBEGIN, SPACE, UNKN,
  318. X/* tokens */       COLON, DATE, EOFILE, ID, KEYW, NUM, SEMI, STRING,
  319. X};
  320. X
  321. X#define AT      SBEGIN  /* class SBEGIN (string begin) is returned by lex. anal. */
  322. X#define SDELIM  '@@'     /* the actual character is needed for string handling*/
  323. X/* these must be changed consistently, for instance to:
  324. X * #define DQUOTE       SBEGIN
  325. X * #define SDELIM       '"'
  326. X * #define AT           IDCHAR
  327. X * there should be no overlap among SDELIM, KDELIM, and VDELIM
  328. X */
  329. X
  330. X/* other characters */
  331. X
  332. X#define ACCENT   IDCHAR
  333. X#define AMPER    IDCHAR
  334. X#define BACKSL   IDCHAR
  335. X#define BAR      IDCHAR
  336. X#define COMMA    UNKN
  337. X#define DIVIDE   IDCHAR
  338. X#define DOLLAR   UNKN                /* overlap with KDELIM */
  339. X#define DQUOTE   IDCHAR
  340. X#define EQUAL    IDCHAR
  341. X#define EXCLA    IDCHAR
  342. X#define GREAT    IDCHAR
  343. X#define HASH     IDCHAR
  344. X#define INSERT   UNKN
  345. X#define LBRACE   IDCHAR
  346. X#define LBRACK   IDCHAR
  347. X#define LESS     IDCHAR
  348. X#define LPARN    IDCHAR
  349. X#define MINUS    IDCHAR
  350. X#define PERCNT   IDCHAR
  351. X#define PLUS     IDCHAR
  352. X#define QUEST    IDCHAR
  353. X#define RBRACE   IDCHAR
  354. X#define RBRACK   IDCHAR
  355. X#define RPARN    IDCHAR
  356. X#define SQUOTE   IDCHAR
  357. X#define TILDE    IDCHAR
  358. X#define TIMES    IDCHAR
  359. X#define UNDER    IDCHAR
  360. X#define UPARR    IDCHAR
  361. X
  362. X
  363. X
  364. X
  365. X/***************************************
  366. X * Data structures for the symbol table
  367. X ***************************************/
  368. X
  369. X
  370. X/* Hash table entry */
  371. Xstruct hshentry {
  372. X        char              * num;      /* pointer to revision number (ASCIZ) */
  373. X        char              * date;     /* pointer to date of checking        */
  374. X        char              * author;   /* login of person checking in        */
  375. X        char              * lockedby; /* who locks the revision             */
  376. X        char              * log;      /* log message requested at checkin   */
  377. X        char              * state;    /* state of revision (Exp by default) */
  378. X        struct branchhead * branches; /* list of first revisions on branches*/
  379. X        struct hshentry   * next;     /* next revision on same branch       */
  380. X        int                 insertlns;/* lines inserted (computed by rlog)  */
  381. X        int                 deletelns;/* lines deleted  (computed by rlog)  */
  382. X        char                selector; /* marks entry for selection/deletion */
  383. X};
  384. X
  385. X/* list element for branch lists */
  386. Xstruct branchhead {
  387. X        struct hshentry   * hsh;
  388. X        struct branchhead * nextbranch;
  389. X};
  390. X
  391. X/* accesslist element */
  392. Xstruct access {
  393. X        char              * login;
  394. X        struct access     * nextaccess;
  395. X};
  396. X
  397. X/* list element for locks  */
  398. Xstruct lock {
  399. X        char              * login;
  400. X        struct hshentry   * delta;
  401. X        struct lock       * nextlock;
  402. X};
  403. X
  404. X/* list element for symbolic names */
  405. Xstruct assoc {
  406. X        char              * symbol;
  407. X        struct hshentry   * delta;
  408. X        struct assoc      * nextassoc;
  409. X};
  410. X
  411. X
  412. X/* common variables (getadmin and getdelta())*/
  413. Xextern char            * Comment;
  414. Xextern struct access   * AccessList;
  415. Xextern struct assoc    * Symbols;
  416. Xextern struct lock     * Locks;
  417. Xextern struct hshentry * Head;
  418. Xextern struct hshentry * Dbranch;
  419. Xextern int               StrictLocks;
  420. Xextern int               TotalDeltas;
  421. X#ifndef lint
  422. Xstatic char copyright[]="Copyright (C) 1982 by Walter F. Tichy";
  423. X#endif
  424. X
  425. X/* common variables (lexical analyzer)*/
  426. Xextern enum tokens map[];
  427. X#define ctab (&map[1])
  428. Xextern enum tokens       nexttok;
  429. Xextern int               hshenter;
  430. Xextern char            * NextString;
  431. Xextern char            * cmdid;
  432. X
  433. X#if defined(USG) || defined(V4_2BSD)
  434. X#define VOID    (void)
  435. X#else
  436. Xtypedef int void;
  437. X#define VOID
  438. X#endif
  439. X
  440. X/* common routines */
  441. Xextern char *talloc();
  442. Xextern int serror();
  443. Xextern int faterror();
  444. Xextern int fatserror();
  445. Xextern void ignoreints();
  446. Xextern void catchints();
  447. Xextern void restoreints();
  448. X
  449. X#ifdef USG
  450. Xextern int sprintf();
  451. X#endif
  452. X
  453. X/*
  454. X * Markers for keyword expansion (used in co and ident)
  455. X */
  456. X#define AUTHOR          "Author"
  457. X#define DATE            "Date"
  458. X#define HEADER          "Header"
  459. X#define IDH             "Id"
  460. X#define LOCKER          "Locker"
  461. X#define LOG             "Log"
  462. X#define RCSFILE         "RCSfile"
  463. X#define REVISION        "Revision"
  464. X#define SOURCE          "Source"
  465. X#define STATE           "State"
  466. X
  467. Xenum markers { Nomatch, Author, Date, Header, Id,
  468. X           Locker, Log, RCSfile, Revision, Source, State };
  469. X
  470. X#define DELNUMFORM      "\n\n%s\n%s\n"
  471. X/* used by putdtext and scanlogtext */
  472. X#define DELETE          'D'
  473. X/* set by rcs -o and used by puttree() in rcssyn */
  474. X
  475. X@
  476. X
  477. X
  478. X4.9.2.1
  479. Xlog
  480. X@Start of Amiga RCS port branch.
  481. X@
  482. Xtext
  483. X@d5 1
  484. Xa5 2
  485. X<<<<<<< rcsbase.h
  486. X#define RCSBASE "$Id: rcsbase.h,v 4.9.1.1 89/08/11 01:42:12 rsbx Exp Locker: rsbx $"
  487. Xa33 3
  488. X=======
  489. X#define RCSBASE "$Id: rcsbase.h,v 1.3 89/09/17 09:54:06 rick Exp $"
  490. X>>>>>>> 1.3
  491. Xa54 9
  492. X<<<<<<< rcsbase.h
  493. X * Revision 4.9.1.1  89/08/11  01:42:12  rsbx
  494. X * Start of cbmvax RCS source branch.
  495. X=======
  496. X * Revision 1.3  89/09/17  09:54:06  rick
  497. X * Change back to original
  498. X>>>>>>> 1.3
  499. X * 
  500. X<<<<<<< rcsbase.h
  501. Xa55 3
  502. X * checked in with -k by rsbx at 89.08.10.16.06.59.
  503. X * 
  504. X * Revision 4.9  89/05/01  15:17:14  narten
  505. Xa69 5
  506. X=======
  507. X * Revision 1.2  88/09/03  15:14:12  rick
  508. X * Port to AmigaDos.  All done with conditional compiles
  509. X * 
  510. X>>>>>>> 1.3
  511. Xa129 1
  512. X<<<<<<< rcsbase.h
  513. Xa134 3
  514. X=======
  515. X#ifndef AMIGA
  516. X>>>>>>> 1.3
  517. Xa135 1
  518. X#endif
  519. Xd137 1
  520. Xa137 4
  521. X#ifdef AMIGA
  522. X#       define rindex    strrchr
  523. X#    define DATEFORM "%02d.%02d.%02d.%02d.%02d.%02d"
  524. X#else
  525. Xa143 1
  526. X#endif
  527. Xa182 4
  528. X#ifdef AMIGA
  529. X#  define NCPFN           256 /* number of characters per filename          */
  530. X#  define NCPPN          1024 /* number of characters per pathname          */
  531. X#else
  532. Xa189 1
  533. X#endif
  534. Xd213 1
  535. Xa213 1
  536. X#ifndef AMIGA
  537. Xa215 1
  538. X#endif
  539. X@
  540. X
  541. X
  542. X4.9.2.2
  543. Xlog
  544. X@Finished the integration of Rick Schaeffer's RCS Amiga port with the RCS
  545. Xsources I have here (and are later than the ones Rick used).
  546. X@
  547. Xtext
  548. X@d5 2
  549. Xa6 1
  550. X#define RCSBASE "$Id: rcsbase.h,v 4.9.2.1 89/10/13 19:16:35 rsbx Exp Locker: rsbx $"
  551. Xd35 3
  552. Xd59 1
  553. Xa59 3
  554. X * Revision 4.9.2.1  89/10/13  19:16:35  rsbx
  555. X * Start of Amiga RCS port branch.
  556. X * 
  557. Xd62 4
  558. Xd67 1
  559. Xd86 5
  560. Xd151 2
  561. Xa152 1
  562. X#if defined(USG) || defined(AMIGA)
  563. Xd157 1
  564. Xd159 1
  565. Xd380 1
  566. Xa380 1
  567. X#if defined(USG) || defined(V4_2BSD) || defined (AMIGA)
  568. X@
  569. X
  570. X
  571. X4.9.2.3
  572. Xlog
  573. X@Changed file path handling to deal with Amiga file path sematics.
  574. X@
  575. Xtext
  576. X@d5 1
  577. Xa5 1
  578. X#define RCSBASE "$Id: rcsbase.h,v 4.9.2.2 89/10/15 15:43:52 rsbx Exp $"
  579. Xa54 4
  580. X * Revision 4.9.2.2  89/10/15  15:43:52  rsbx
  581. X * Finished the integration of Rick Schaeffer's RCS Amiga port with the RCS
  582. X * sources I have here (and are later than the ones Rick used).
  583. X * 
  584. Xa149 1
  585. X#    define index    strchr
  586. X@
  587. X
  588. X
  589. X4.9.2.4
  590. Xlog
  591. X@Changes to make the delete bit to track the write bit. Made protection
  592. Xbit manipulation less insane.
  593. X@
  594. Xtext
  595. X@d5 1
  596. Xa5 1
  597. X#define RCSBASE "$Id: rcsbase.h,v 4.9.2.3 89/10/16 19:07:02 rsbx Exp $"
  598. Xa54 3
  599. X * Revision 4.9.2.3  89/10/16  19:07:02  rsbx
  600. X * Changed file path handling to deal with Amiga file path sematics.
  601. X * 
  602. Xd230 7
  603. Xa236 7
  604. X#define NEWRCSFILE  ",RCSnewXXXXXXXX"
  605. X#define DIFFILE     ",RCSciXXXXXXXX"
  606. X#define TMPFILE1    ",RCSt1XXXXXXXX"
  607. X#define TMPFILE2    ",RCSt2XXXXXXXX"
  608. X#define TMPFILE3    ",RCSt3XXXXXXXX"
  609. X#define JOINFIL2    ",RCSj2XXXXXXXX"
  610. X#define JOINFIL3    ",RCSj3XXXXXXXX"
  611. Xa246 3
  612. X#ifdef AMIGA
  613. X#define WORKMODE(RCSmode) (RCSmode&~(S_IWRITE|S_IDELETE))|((lockflag||!StrictLocks)?S_IWRITE|S_IREAD|S_IDELETE:0)
  614. X#else
  615. Xa247 1
  616. X#endif
  617. X@
  618. X
  619. X
  620. X4.9.1.1
  621. Xlog
  622. X@Start of cbmvax RCS source branch.
  623. X@
  624. Xtext
  625. X@a55 3
  626. X * checked in with -k by rsbx at 89.08.10.16.06.59.
  627. X * 
  628. X * Revision 4.9  89/05/01  15:17:14  narten
  629. X@
  630. SHAR_EOF
  631. echo "extracting rcs/rcs.rcsfiles/rcsdiff.c,v"
  632. sed 's/^X//' << \SHAR_EOF > rcs/rcs.rcsfiles/rcsdiff.c,v
  633. Xhead     4.6;
  634. Xbranch   4.6.2;
  635. Xaccess   ;
  636. Xsymbols  amiga_rcs:4.6.2 cbmvax_source:4.6.1 uunet_june89_dist:4.6;
  637. Xlocks    ; strict;
  638. Xcomment  @ * @;
  639. X
  640. X
  641. X4.6
  642. Xdate     89.05.01.15.12.27;  author narten;  state Exp;
  643. Xbranches 4.6.1.1 4.6.2.1;
  644. Xnext     ;
  645. X
  646. X4.6.1.1
  647. Xdate     89.08.11.01.42.22;  author rsbx;  state Exp;
  648. Xbranches ;
  649. Xnext     ;
  650. X
  651. X4.6.2.1
  652. Xdate     89.10.13.19.18.20;  author rsbx;  state Exp;
  653. Xbranches ;
  654. Xnext     4.6.2.2;
  655. X
  656. X4.6.2.2
  657. Xdate     89.10.15.15.44.03;  author rsbx;  state Exp;
  658. Xbranches ;
  659. Xnext     4.6.2.3;
  660. X
  661. X4.6.2.3
  662. Xdate     89.11.12.15.07.26;  author rsbx;  state Exp;
  663. Xbranches ;
  664. Xnext     ;
  665. X
  666. X
  667. Xdesc
  668. X@RCS rcsdiff operation.
  669. X@
  670. X
  671. X
  672. X
  673. X4.6
  674. Xlog
  675. X@checked in with -k by rsbx at 89.08.10.16.19.11.
  676. X@
  677. Xtext
  678. X@/*
  679. X *                     RCS rcsdiff operation
  680. X */
  681. X#ifndef lint
  682. Xstatic char rcsid[]=
  683. X"$Header: /usr/src/local/bin/rcs/src/RCS/rcsdiff.c,v 4.6 89/05/01 15:12:27 narten Exp $ Purdue CS";
  684. X#endif
  685. X/*****************************************************************************
  686. X *                       generate difference between RCS revisions
  687. X *****************************************************************************
  688. X */
  689. X
  690. X/* Copyright (C) 1982, 1988, 1989 Walter Tichy
  691. X * All rights reserved.
  692. X *
  693. X * Redistribution and use in source and binary forms are permitted
  694. X * provided that the above copyright notice and this paragraph are
  695. X * duplicated in all such forms and that any documentation,
  696. X * advertising materials, and other materials related to such
  697. X * distribution and use acknowledge that the software was developed
  698. X * by Walter Tichy.
  699. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  700. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  701. X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  702. X *
  703. X * Report all problems and direct all questions to:
  704. X *   rcs-bugs@@cs.purdue.edu
  705. X * 
  706. X
  707. X
  708. X
  709. X
  710. X
  711. X
  712. X
  713. X*/
  714. X
  715. X
  716. X
  717. X
  718. X/* $Log:    rcsdiff.c,v $
  719. X * Revision 4.6  89/05/01  15:12:27  narten
  720. X * changed copyright header to reflect current distribution rules
  721. X * 
  722. X * Revision 4.5  88/11/08  12:01:51  narten
  723. X * changes from  eggert@@sm.unisys.com (Paul Eggert)
  724. X * 
  725. X * Revision 4.5  88/08/09  19:12:41  eggert
  726. X * Use execv(), not system(); yield exit status like diff(1)s; allow cc -R.
  727. X * 
  728. X * Revision 4.4  87/12/18  11:37:46  narten
  729. X * changes Jay Lepreau made in the 4.3 BSD version, to add support for
  730. X * "-i", "-w", and "-t" flags and to permit flags to be bundled together, 
  731. X * merged in.
  732. X * 
  733. X * Revision 4.3  87/10/18  10:31:42  narten
  734. X * Updating version numbers. Changes relative to 1.1 actually
  735. X * relative to 4.1
  736. X * 
  737. X * Revision 1.3  87/09/24  13:59:21  narten
  738. X * Sources now pass through lint (if you ignore printf/sprintf/fprintf 
  739. X * warnings)
  740. X * 
  741. X * Revision 1.2  87/03/27  14:22:15  jenkins
  742. X * Port to suns
  743. X * 
  744. X * Revision 1.1  84/01/23  14:50:18  kcs
  745. X * Initial revision
  746. X * 
  747. X * Revision 4.1  83/05/03  22:13:19  wft
  748. X * Added default branch, option -q, exit status like diff.
  749. X * Added fterror() to replace faterror().
  750. X * 
  751. X * Revision 3.6  83/01/15  17:52:40  wft
  752. X * Expanded mainprogram to handle multiple RCS files.
  753. X *
  754. X * Revision 3.5  83/01/06  09:33:45  wft
  755. X * Fixed passing of -c (context) option to diff.
  756. X *
  757. X * Revision 3.4  82/12/24  15:28:38  wft
  758. X * Added call to catchsig().
  759. X *
  760. X * Revision 3.3  82/12/10  16:08:17  wft
  761. X * Corrected checking of return code from diff; improved error msgs.
  762. X *
  763. X * Revision 3.2  82/12/04  13:20:09  wft
  764. X * replaced getdelta() with gettree(). Changed diagnostics.
  765. X *
  766. X * Revision 3.1  82/11/28  19:25:04  wft
  767. X * Initial revision.
  768. X *
  769. X */
  770. X#include <ctype.h>
  771. X#include "rcsbase.h"
  772. X#define ERRCODE 2                   /*error code for exit status            */
  773. Xextern char *rindex();
  774. X#ifndef lint
  775. Xstatic char rcsbaseid[] = RCSBASE;
  776. X#endif
  777. Xstatic char co[] = CO;
  778. X
  779. Xextern int    cleanup();            /* cleanup after signals                */
  780. Xextern char * mktempfile();         /*temporary file name generator         */
  781. Xextern int    fterror();            /*forward for special fatal error func. */
  782. Xextern struct hshentry * genrevs(); /*generate delta numbers                */
  783. Xextern int    nerror;               /*counter for errors                    */
  784. Xextern int    quietflag;            /*suppresses diagnostics                */
  785. Xextern FILE * finptr;               /* RCS input file                       */
  786. X
  787. Xchar *RCSfilename;
  788. Xchar *workfilename;
  789. Xchar * temp1file, * temp2file;
  790. X
  791. Xchar bops[10];
  792. Xchar otherops[10];
  793. X
  794. Xmain (argc, argv)
  795. Xint argc; char **argv;
  796. X{
  797. X        char * cmdusage;
  798. X    char commarg[revlength+3];
  799. X        int  revnums;                 /* counter for revision numbers given */
  800. X        char * rev1, * rev2;          /* revision numbers from command line */
  801. X        char numericrev[revlength];   /* holds expanded revision number     */
  802. X        char * xrev1, * xrev2;        /* expanded revision numbers          */
  803. X        struct hshentry * gendeltas[hshsize];/*stores deltas to be generated*/
  804. X        struct hshentry * target;
  805. X    char * boption, * otheroption;
  806. X        int  exit_stats;
  807. X    int  diffs_found;
  808. X    char *argp;
  809. X    register c;
  810. X
  811. X        catchints();
  812. X        otheroption = otherops + 2;
  813. X    boption = bops + 2;
  814. X        cmdid = "rcsdiff";
  815. X    cmdusage = "command format:\n    rcsdiff [-biwt] [-q] [-cefhn] [-rrev1] [-rrev2] file";
  816. X    diffs_found=revnums=0;
  817. X        while (--argc,++argv, argc>=1 && ((*argv)[0] == '-')) {
  818. X        argp = &((*argv)[1]);
  819. X        while (c = *argp++) switch (c) {
  820. X                case 'r':
  821. X                if (*argp!='\0') {
  822. X                            if (revnums==0) {
  823. X                                    rev1= argp; revnums=1;
  824. X                            } elif (revnums==1) {
  825. X                                    rev2= argp; revnums=2;
  826. X                            } else {
  827. X                    fterror("too many revision numbers");
  828. X                            }
  829. X                        } /* do nothing for empty -r */
  830. X            argp += strlen(argp);
  831. X                        break;
  832. X                case 'b':
  833. X                case 'i':
  834. X                case 'w':
  835. X                case 't':
  836. X            if (!rindex(bops + 2, c))
  837. X                *boption++ = c;
  838. X            break;
  839. X        case 'q':
  840. X            quietflag=true;
  841. X            break;
  842. X                case 'c':
  843. X                case 'e':
  844. X                case 'f':
  845. X                case 'h':
  846. X                case 'n':
  847. X                        if (otheroption == otherops + 2) {
  848. X                *otheroption++ = c;
  849. X                if (c == 'c' && isdigit(*argp)) {
  850. X                    while (isdigit(*argp) && otheroption < otherops+sizeof(otherops)-1)
  851. X                        *otheroption++ = *argp++;
  852. X                    if (*argp)
  853. X                        faterror("-c: bad count");
  854. X                    argp = "";
  855. X                }
  856. X                        } else {
  857. X                fterror("Options c,e,f,h,n are mutually exclusive");
  858. X                        }
  859. X            break;
  860. X                default:
  861. X            fterror("unknown option: %s\n%s", *argv,cmdusage);
  862. X                };
  863. X        } /* end of option processing */
  864. X
  865. X    if (boption != bops + 2) {
  866. X        bops[0] = ' ';
  867. X        bops[1] = '-';
  868. X        boption = bops;
  869. X    }
  870. X    if (otheroption != otherops + 2) {
  871. X         otherops[0] = ' ';
  872. X        otherops[1] = '-';
  873. X        otheroption = otherops;
  874. X    }
  875. X    if (argc<1) fterror("No input file\n%s",cmdusage);
  876. X
  877. X        /* now handle all filenames */
  878. X        do {
  879. X                finptr=NULL;
  880. X
  881. X                if (pairfilenames(argc,argv,true,false)!=1) continue;
  882. X        diagnose("===================================================================");
  883. X                diagnose("RCS file: %s",RCSfilename);
  884. X                if (revnums<2 && !(access(workfilename,4)==0)) {
  885. X                        error("Can't open %s",workfilename);
  886. X                        continue;
  887. X                }
  888. X                if (!trysema(RCSfilename,false)) continue; /* give up */
  889. X
  890. X
  891. X                gettree(); /* reads in the delta tree */
  892. X
  893. X                if (Head==nil) {
  894. X                        error("no revisions present");
  895. X                        continue;
  896. X                }
  897. X                if (revnums==0)
  898. X                        rev1=Dbranch!=nil?Dbranch->num:Head->num; /* default rev1 */
  899. X
  900. X                if (!expandsym(rev1,numericrev)) continue;
  901. X                if (!(target=genrevs(numericrev,(char *)nil,(char *)nil,(char *)nil,gendeltas))) continue;
  902. X                xrev1=target->num;
  903. X
  904. X                if (revnums==2) {
  905. X                        if (!expandsym(rev2,numericrev)) continue;
  906. X                        if (!(target=genrevs(numericrev,(char *)nil,(char *)nil,(char *)nil,gendeltas))) continue;
  907. X                        xrev2=target->num;
  908. X                }
  909. X
  910. X
  911. X                temp1file=mktempfile("/tmp/",TMPFILE1);
  912. X                diagnose("retrieving revision %s",xrev1);
  913. X                VOID sprintf(commarg,"-p%s",xrev1);
  914. X                if (run((char*)nil,temp1file, co,"-q",commarg,RCSfilename,(char*)nil)){
  915. X                        error("co failed");
  916. X                        continue;
  917. X                }
  918. X                if (revnums<=1) {
  919. X                        temp2file=workfilename;
  920. X                        diagnose("diff%s%s -r%s %s",boption,otheroption,xrev1,workfilename);
  921. X                } else {
  922. X                        temp2file=mktempfile("/tmp/",TMPFILE2);
  923. X                        diagnose("retrieving revision %s",xrev2);
  924. X            VOID sprintf(commarg,"-p%s",xrev2);
  925. X                        if (run((char*)nil,temp2file, co,"-q",commarg,RCSfilename,(char *)nil)){
  926. X                                error("co failed");
  927. X                                continue;
  928. X                        }
  929. X                        diagnose("diff%s%s -r%s -r%s",boption,otheroption,xrev1,xrev2);
  930. X                }
  931. X
  932. X                exit_stats =
  933. X            *boption
  934. X            ? *otheroption
  935. X              ? run((char*)nil,(char*)nil, DIFF, boption+1,    otheroption+1,    temp1file,temp2file,(char*)nil)
  936. X              : run((char*)nil,(char*)nil, DIFF, boption+1,            temp1file,temp2file,(char*)nil)
  937. X            : *otheroption
  938. X              ? run((char*)nil,(char*)nil, DIFF,         otheroption+1,    temp1file,temp2file,(char*)nil)
  939. X              : run((char*)nil,(char*)nil, DIFF,                 temp1file,temp2file,(char*)nil);
  940. X
  941. X                if (exit_stats == (1 << BYTESIZ))
  942. X            diffs_found = 1;
  943. X                else if (exit_stats != 0) {
  944. X                        error ("diff failed");
  945. X                        continue;
  946. X                }
  947. X        } while (cleanup(),
  948. X                 ++argv, --argc >=1);
  949. X
  950. X
  951. X        exit(nerror ? ERRCODE : diffs_found);
  952. X}
  953. X
  954. X
  955. X/*VARARGS3*/
  956. Xfterror(e, e1, e2)
  957. Xchar * e, * e1, * e2;
  958. X/* prints error message and terminates program with ERRCODE */
  959. X{       nerror++;
  960. X        VOID fprintf(stderr,"%s error: ",cmdid);
  961. X    VOID fprintf(stderr,e, e1, e2);
  962. X        VOID fprintf(stderr,"\n%s aborted\n",cmdid);
  963. X        VOID cleanup();
  964. X    exit(ERRCODE);
  965. X}
  966. X
  967. X@
  968. X
  969. X
  970. X4.6.2.1
  971. Xlog
  972. X@Start of Amiga RCS port branch.
  973. X@
  974. Xtext
  975. X@d6 1
  976. Xa6 5
  977. X<<<<<<< rcsdiff.c
  978. X"$Header: /u/softeng/rsbx/rcs/amiga/RCS.cbmvax/rcsdiff.c,v 4.6.1.1 89/08/11 01:42:22 rsbx Exp Locker: rsbx $ Purdue CS";
  979. X=======
  980. X"$Header: /u/softeng/rsbx/rcs/amiga/RCS/rcsdiff.c,v 1.2 89/09/17 13:35:25 rick Exp $ Purdue CS";
  981. X>>>>>>> 1.2
  982. Xa41 11
  983. X<<<<<<< rcsdiff.c
  984. X * Revision 4.6.1.1  89/08/11  01:42:22  rsbx
  985. X * Start of cbmvax RCS source branch.
  986. X=======
  987. X * Revision 1.2  89/09/17  13:35:25  rick
  988. X * Port to AmigaDos done by Rick Schaeffer (ricks@@iscuva.iscs.com)
  989. X * All changes done with conditional compile (#ifdef AMIGA).  This version
  990. X * compiles correctly with Lattice C version 5.02 or later.
  991. X>>>>>>> 1.2
  992. X * 
  993. X<<<<<<< rcsdiff.c
  994. Xa42 3
  995. X * checked in with -k by rsbx at 89.08.10.16.19.11.
  996. X * 
  997. X * Revision 4.6  89/05/01  15:12:27  narten
  998. Xa50 8
  999. X=======
  1000. X * Revision 1.3  89/09/10  09:27:39  rick
  1001. X * Moved TARGETDIR to rcs:
  1002. X * 
  1003. X * Revision 1.2  88/09/03  15:09:44  rick
  1004. X * Port to AmigaDos.  All done with conditional compiles
  1005. X * 
  1006. X>>>>>>> 1.2
  1007. Xa101 6
  1008. X#ifdef AMIGA
  1009. X#define DTMPFILE1    ",RDFt1XXXXXX"
  1010. X#define DTMPFILE2    ",RDFt2XXXXXX"
  1011. X#define DTMPFILE3    ",RDFt3XXXXXX"
  1012. X#endif
  1013. X
  1014. Xa233 3
  1015. X#ifdef AMIGA
  1016. X                temp1file=mktempfile("t:",DTMPFILE1);
  1017. X#else
  1018. Xa234 1
  1019. X#endif
  1020. Xa235 1
  1021. X<<<<<<< rcsdiff.c
  1022. Xa237 5
  1023. X=======
  1024. X                VOID sprintf(command,"%sco -q -p%s %s >%s\n",
  1025. X                        TARGETDIR,xrev1,RCSfilename,temp1file);
  1026. X                if (system(command)){
  1027. X>>>>>>> 1.2
  1028. Xa244 3
  1029. X#ifdef AMIGA
  1030. X                        temp2file=mktempfile("t:",DTMPFILE2);
  1031. X#else
  1032. Xa245 1
  1033. X#endif
  1034. Xa246 1
  1035. X<<<<<<< rcsdiff.c
  1036. Xa248 5
  1037. X=======
  1038. X                        VOID sprintf(command,"%sco -q -p%s %s >%s\n",
  1039. X                                TARGETDIR,xrev2,RCSfilename,temp2file);
  1040. X                        if (system(command)){
  1041. X>>>>>>> 1.2
  1042. X@
  1043. X
  1044. X
  1045. X4.6.2.2
  1046. Xlog
  1047. X@Finished the integration of Rick Schaeffer's RCS Amiga port with the RCS
  1048. Xsources I have here (and are later than the ones Rick used).
  1049. X@
  1050. Xtext
  1051. X@d6 5
  1052. Xa10 1
  1053. X"$Header: /u/softeng/rsbx/rcs/amiga/RCS/rcsdiff.c,v 4.6.2.1 89/10/13 19:18:20 rsbx Exp Locker: rsbx $ Purdue CS";
  1054. Xd46 1
  1055. Xa46 3
  1056. X * Revision 4.6.2.1  89/10/13  19:18:20  rsbx
  1057. X * Start of Amiga RCS port branch.
  1058. X * 
  1059. Xd49 6
  1060. Xd56 1
  1061. Xd69 8
  1062. Xd272 1
  1063. Xd275 5
  1064. Xd293 1
  1065. Xd296 5
  1066. X@
  1067. X
  1068. X
  1069. X4.6.2.3
  1070. Xlog
  1071. X@WaitChild() on the Amiga returns the completion code from a child process
  1072. Xwithout shifting it up 8 bits like the Unix wait() does.
  1073. X@
  1074. Xtext
  1075. X@d6 1
  1076. Xa6 1
  1077. X"$Header: /u/softeng/rsbx/rcs/amiga/RCS/rcsdiff.c,v 4.6.2.2 89/10/15 15:44:03 rsbx Exp $ Purdue CS";
  1078. Xa41 4
  1079. X * Revision 4.6.2.2  89/10/15  15:44:03  rsbx
  1080. X * Finished the integration of Rick Schaeffer's RCS Amiga port with the RCS
  1081. X * sources I have here (and are later than the ones Rick used).
  1082. X * 
  1083. Xa286 3
  1084. X#ifdef AMIGA
  1085. X                if (exit_stats == 1)
  1086. X#else
  1087. Xa287 1
  1088. X#endif
  1089. X@
  1090. X
  1091. X
  1092. X4.6.1.1
  1093. Xlog
  1094. X@Start of cbmvax RCS source branch.
  1095. X@
  1096. Xtext
  1097. X@d6 1
  1098. Xa6 1
  1099. X"$Header: /u/softeng/rsbx/rcs/rcs.uunet/src/RCS/rcsdiff.c,v 4.6 89/05/01 15:12:27 narten Exp $ Purdue CS";
  1100. Xa41 3
  1101. X * Revision 4.6  89/05/01  15:12:27  narten
  1102. X * checked in with -k by rsbx at 89.08.10.16.19.11.
  1103. X * 
  1104. X@
  1105. SHAR_EOF
  1106. echo "extracting rcs/rcs.rcsfiles/rcsclean.c,v"
  1107. sed 's/^X//' << \SHAR_EOF > rcs/rcs.rcsfiles/rcsclean.c,v
  1108. Xhead     4.4;
  1109. Xbranch   4.4.2;
  1110. Xaccess   ;
  1111. Xsymbols  amiga_rcs:4.4.2 cbmvax_source:4.4.1 uunet_june89_dist:4.4;
  1112. Xlocks    ; strict;
  1113. Xcomment  @ * @;
  1114. X
  1115. X
  1116. X4.4
  1117. Xdate     89.05.01.15.12.21;  author narten;  state Exp;
  1118. Xbranches 4.4.1.1 4.4.2.1;
  1119. Xnext     ;
  1120. X
  1121. X4.4.1.1
  1122. Xdate     89.08.11.01.42.15;  author rsbx;  state Exp;
  1123. Xbranches ;
  1124. Xnext     ;
  1125. X
  1126. X4.4.2.1
  1127. Xdate     89.10.13.19.18.16;  author rsbx;  state Exp;
  1128. Xbranches ;
  1129. Xnext     4.4.2.2;
  1130. X
  1131. X4.4.2.2
  1132. Xdate     89.10.15.15.43.57;  author rsbx;  state Exp;
  1133. Xbranches ;
  1134. Xnext     ;
  1135. X
  1136. X
  1137. Xdesc
  1138. X@RCS rcsclean operation.
  1139. X@
  1140. X
  1141. X
  1142. X
  1143. X4.4
  1144. Xlog
  1145. X@checked in by rsbx at 89.08.10.16.15.55.
  1146. X@
  1147. Xtext
  1148. X@/*
  1149. X *                     RCS rcsclean operation
  1150. X */
  1151. X
  1152. Xstatic char rcsid[]=
  1153. X"$Header $ Purdue CS";
  1154. X/*****************************************************************************
  1155. X *                       remove unneded working files
  1156. X *****************************************************************************
  1157. X */
  1158. X
  1159. X/* Copyright (C) 1982, 1988, 1989 Walter Tichy
  1160. X * All rights reserved.
  1161. X *
  1162. X * Redistribution and use in source and binary forms are permitted
  1163. X * provided that the above copyright notice and this paragraph are
  1164. X * duplicated in all such forms and that any documentation,
  1165. X * advertising materials, and other materials related to such
  1166. X * distribution and use acknowledge that the software was developed
  1167. X * by Walter Tichy.
  1168. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  1169. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  1170. X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1171. X *
  1172. X * Report all problems and direct all questions to:
  1173. X *   rcs-bugs@@cs.purdue.edu
  1174. X * 
  1175. X
  1176. X
  1177. X
  1178. X
  1179. X
  1180. X
  1181. X
  1182. X*/
  1183. X
  1184. X
  1185. X
  1186. X
  1187. X/* $Log:    rcsclean.c,v $
  1188. X * Revision 4.4  89/05/01  15:12:21  narten
  1189. X * changed copyright header to reflect current distribution rules
  1190. X * 
  1191. X * Revision 4.3  88/11/08  15:59:54  narten
  1192. X * removed reference to TARGETDIR
  1193. X * 
  1194. X * Revision 4.2  87/10/18  10:30:43  narten
  1195. X * Updating version numbers. Changes relative to 1.1 are actually
  1196. X * relative to 4.1
  1197. X * 
  1198. X * Revision 1.2  87/09/24  13:59:13  narten
  1199. X * Sources now pass through lint (if you ignore printf/sprintf/fprintf 
  1200. X * warnings)
  1201. X * 
  1202. X * Revision 1.1  84/01/23  14:50:16  kcs
  1203. X * Initial revision
  1204. X * 
  1205. X * Revision 4.1  83/12/15  12:26:18  wft
  1206. X * Initial revision.
  1207. X * 
  1208. X */
  1209. X#include "rcsbase.h"
  1210. X#define ERRCODE 2                   /*error code for exit status            */
  1211. Xstatic char rcsbaseid[] = RCSBASE;
  1212. X
  1213. Xextern int    cleanup();            /* cleanup after signals                */
  1214. Xextern char * mktempfile();         /*temporary file name generator         */
  1215. Xextern int    fterror();            /*forward for special fatal error func. */
  1216. Xextern struct hshentry * genrevs(); /*generate delta numbers                */
  1217. Xextern int    nerror;               /*counter for errors                    */
  1218. Xextern int    quietflag;            /*suppresses diagnostics                */
  1219. Xextern FILE * finptr;               /* RCS input file                       */
  1220. Xextern FILE * fopen();
  1221. X
  1222. Xchar *RCSfilename;
  1223. Xchar *workfilename;
  1224. Xchar * tempfile;
  1225. XFILE * file1, * file2;              /*file descriptors for comparison       */
  1226. X
  1227. Xmain (argc, argv)
  1228. Xint argc; char **argv;
  1229. X{
  1230. X        char * cmdusage;
  1231. X        char command[NCPPN+revlength+40];
  1232. X    char * rev;                   /* revision number from command line  */
  1233. X        char numericrev[revlength];   /* holds expanded revision number     */
  1234. X    int  revnums;                 /* number of -r options               */
  1235. X        struct hshentry * gendeltas[hshsize];/*stores deltas to be generated*/
  1236. X        struct hshentry * target;
  1237. X        int  filecounter;
  1238. X    register int c1;              /* reading input                      */
  1239. X    int  result;                  /* result of comparison               */
  1240. X    int pairresult;               /* reulst of pairfilenames            */
  1241. X
  1242. X        catchints();
  1243. X    cmdid = "rcsclean";
  1244. X    cmdusage = "command format:\n    rcsclean [-rrev] file";
  1245. X        filecounter=revnums=0;
  1246. X    quietflag=true; /* default no diagnostics */
  1247. X        while (--argc,++argv, argc>=1 && ((*argv)[0] == '-')) {
  1248. X                switch ((*argv)[1]) {
  1249. X                case 'r':
  1250. X        revno:  if ((*argv)[2]!='\0') {
  1251. X                            if (revnums==0) {
  1252. X                    rev= *argv+2; revnums=1;
  1253. X                            } else {
  1254. X                    fterror("too many revision numbers");
  1255. X                            }
  1256. X                        } /* do nothing for empty -r */
  1257. X                        break;
  1258. X        case 'D': /* debug option */
  1259. X            quietflag = false;
  1260. X            break;
  1261. X
  1262. X                default:
  1263. X            fterror("unknown option: %s\n%s", *argv,cmdusage);
  1264. X                };
  1265. X        } /* end of option processing */
  1266. X
  1267. X    if (argc<1) fterror("No input file\n%s",cmdusage);
  1268. X
  1269. X        /* now handle all filenames */
  1270. X        do {
  1271. X                finptr=NULL;
  1272. X        pairresult=pairfilenames(argc,argv,false,false);
  1273. X
  1274. X        if (pairresult==0) continue; /* error */
  1275. X        if (!(access(workfilename,4)==0)) {
  1276. X            diagnose("Can't open %s",workfilename);
  1277. X                        continue;
  1278. X        } elsif (pairresult == -1) {
  1279. X            warn("Can't find RCS file for %s",workfilename);
  1280. X            continue;
  1281. X        }
  1282. X                diagnose("RCS file: %s",RCSfilename);
  1283. X                if (!trysema(RCSfilename,false)) continue; /* give up */
  1284. X
  1285. X
  1286. X                gettree(); /* reads in the delta tree */
  1287. X
  1288. X                if (Head==nil) {
  1289. X                        error("no revisions present");
  1290. X                        continue;
  1291. X                }
  1292. X                if (revnums==0)
  1293. X            rev=(Dbranch!=nil?Dbranch->num:Head->num); /* default rev1 */
  1294. X
  1295. X        if (!expandsym(rev,numericrev)) continue;
  1296. X                if (!(target=genrevs(numericrev,nil,nil,nil,gendeltas))) continue;
  1297. X
  1298. X        tempfile=mktempfile("/tmp/",TMPFILE1);
  1299. X        diagnose("retrieving revision %s",target->num);
  1300. X                VOID sprintf(command,"%s -q -p%s %s > %s\n",
  1301. X            CO ,target->num,RCSfilename,tempfile);
  1302. X                if (system(command)){
  1303. X                        error("co failed");
  1304. X                        continue;
  1305. X                }
  1306. X        /* now do comparison */
  1307. X        if ((file1=fopen(tempfile,"r"))==NULL) {
  1308. X            error("Can't open checked out file %s",tempfile);
  1309. X            continue;
  1310. X        }
  1311. X        if ((file2=fopen(workfilename,"r"))==NULL) {
  1312. X            error("Can't open %s",workfilename);
  1313. X            continue;
  1314. X        }
  1315. X        result=1;
  1316. X        while ((c1=getc(file1))==getc(file2)) {
  1317. X            if (c1==EOF) {
  1318. X                /* identical files; can remove working file */
  1319. X                result=0;
  1320. X                diagnose("files identical; %s removed",workfilename);
  1321. X                if (unlink(workfilename)!=0) {
  1322. X                    error("Can't unlink %s",workfilename);
  1323. X                }
  1324. X                break;
  1325. X            }
  1326. X        }
  1327. X        fclose(file1); fclose(file2);
  1328. X
  1329. X        if (result==1) diagnose ("files different");
  1330. X
  1331. X
  1332. X        } while (cleanup(),
  1333. X                 ++argv, --argc >=1);
  1334. X
  1335. X
  1336. X    if (nerror>0) {
  1337. X        exit(ERRCODE);
  1338. X    } else {
  1339. X        exit(result);
  1340. X    }
  1341. X
  1342. X}
  1343. X
  1344. X
  1345. Xfterror(e, e1, e2)
  1346. Xchar * e, * e1, * e2;
  1347. X/* prints error message and terminates program with ERRCODE */
  1348. X{       nerror++;
  1349. X        VOID fprintf(stderr,"%s error: ",cmdid);
  1350. X    VOID fprintf(stderr,e, e1, e2);
  1351. X        VOID fprintf(stderr,"\n%s aborted\n",cmdid);
  1352. X        VOID cleanup();
  1353. X    exit(ERRCODE);
  1354. X}
  1355. X
  1356. X@
  1357. X
  1358. X
  1359. X4.4.2.1
  1360. Xlog
  1361. X@Start of Amiga RCS port branch.
  1362. X@
  1363. Xtext
  1364. X@a40 11
  1365. X<<<<<<< rcsclean.c
  1366. X * Revision 4.4.1.1  89/08/11  01:42:15  rsbx
  1367. X * Start of cbmvax RCS source branch.
  1368. X=======
  1369. X * Revision 1.2  89/09/17  13:35:21  rick
  1370. X * Port to AmigaDos done by Rick Schaeffer (ricks@@iscuva.iscs.com)
  1371. X * All changes done with conditional compile (#ifdef AMIGA).  This version
  1372. X * compiles correctly with Lattice C version 5.02 or later.
  1373. X>>>>>>> 1.2
  1374. X * 
  1375. X<<<<<<< rcsclean.c
  1376. Xa41 3
  1377. X * checked in by rsbx at 89.08.10.16.15.55.
  1378. X * 
  1379. X * Revision 4.4  89/05/01  15:12:21  narten
  1380. Xa46 8
  1381. X=======
  1382. X * Revision 1.3  89/09/10  09:27:22  rick
  1383. X * Moved TARGETDIR to rcs:
  1384. X * 
  1385. X * Revision 1.2  88/09/03  15:09:35  rick
  1386. X * Port to AmigaDos.  All done with conditional compiles
  1387. X * 
  1388. X>>>>>>> 1.2
  1389. Xa150 3
  1390. X#ifdef AMIGA
  1391. X        tempfile=mktempfile("t:",TMPFILE1);
  1392. X#else
  1393. Xa151 1
  1394. X#endif
  1395. Xa152 1
  1396. X<<<<<<< rcsclean.c
  1397. Xa154 4
  1398. X=======
  1399. X                sprintf(command,"%sco -q -p%s %s >%s\n",
  1400. X            TARGETDIR,target->num,RCSfilename,tempfile);
  1401. X>>>>>>> 1.2
  1402. Xa173 1
  1403. X                fclose(file2); file2 = NULL;
  1404. Xd180 1
  1405. Xa180 4
  1406. X        if (file1)
  1407. X            fclose(file1);
  1408. X        if (file2)
  1409. X            fclose(file2);
  1410. X@
  1411. X
  1412. X
  1413. X4.4.2.2
  1414. Xlog
  1415. X@Finished the integration of Rick Schaeffer's RCS Amiga port with the RCS
  1416. Xsources I have here (and are later than the ones Rick used).
  1417. X@
  1418. Xtext
  1419. X@d41 1
  1420. Xa41 3
  1421. X * Revision 4.4.2.1  89/10/13  19:18:16  rsbx
  1422. X * Start of Amiga RCS port branch.
  1423. X * 
  1424. Xd44 6
  1425. Xd51 1
  1426. Xd61 8
  1427. Xd179 1
  1428. Xd182 4
  1429. X@
  1430. X
  1431. X
  1432. X4.4.1.1
  1433. Xlog
  1434. X@Start of cbmvax RCS source branch.
  1435. X@
  1436. Xtext
  1437. X@a41 3
  1438. X * checked in by rsbx at 89.08.10.16.15.55.
  1439. X * 
  1440. X * Revision 4.4  89/05/01  15:12:21  narten
  1441. X@
  1442. SHAR_EOF
  1443. echo "End of archive 8 (of 14)"
  1444. # if you want to concatenate archives, remove anything after this line
  1445. exit
  1446.